import request from "@/utils/request";



enum ADMIN {
    ADMINLOGIN = '/user/admin',
    PUDATEPASS = '/user/admin/updatepass',
    FINDALL = "/user/list",
    ADMINADD = "/user/admin/adduser",
    SEARCH = '/user/search',
    ROLE = '/user/admin/role'
}

//后台登录
export const Admin_Loing = (data: any) => request({
    method: "POST",
    url: ADMIN.ADMINLOGIN,
    data
})

//登录后台用户更新密码
export const updatepass = (data: any) => request({
    method: "POST",
    url: ADMIN.PUDATEPASS,
    data
})
//用户列表
export const findAlluser = (limit: number, role = "3", keyword = "") => request({
    method: "POST",
    url: ADMIN.FINDALL + `/${limit}` + `/${role}`,
    data: {
        keyword: keyword
    }
})

//管理员添加用户
export const Admin_user = (data: { username: string, password: string, qqnumber: string }) => request({
    method: "POST",
    url: ADMIN.ADMINADD,
    data
})
//查找用户
export const SearchUser = (word: string) => request({
    method: "GET",
    url: ADMIN.SEARCH + `/${word}`,

})

//修改限权
export const updateRole = (data: { id: string, role: string }) => request({
    method: "POST",
    url: ADMIN.ROLE,
    data
})

//删除用户
export const deleteone = (id: string) => request({
    method: "DELETE",
    url: '/user',
    data: {
        id: id
    }
})